package com.demo.wechatweather.controller;


import com.demo.wechatweather.VO.*;
import com.demo.wechatweather.service.CityDataService;
import com.demo.wechatweather.service.WeatherDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/weather")
public class WeatherController {
    @Autowired
    CityDataService cityDataService;

    @Autowired
    WeatherDataService weatherDataService;
    @GetMapping("/cityId/{cityId}")

    public WeatherResponse getWeatherByCityId(@PathVariable("cityId") String cityId){
        return weatherDataService.getDataByCityId(cityId);
    }


    @GetMapping("/cityName/{cityName}")
    public WeatherResponse getWeatherByCityName(@PathVariable("cityName") String cityName){
        return weatherDataService.getDataByCityName(cityName);
    }

    @GetMapping("/look")
    public List<City> look() throws Exception {
        return cityDataService.listCity();
    }

}
